
const toast = ({ title = '加载中...',icon = 'none',duration = 2000,mask = true } = {}) =>{
  wx.showToast({
    title,
    icon, // success(成功) error(失败) loading(加载) none(不显示)
    duration,
    mask //是否显示透明蒙层，防止触摸穿透
  })
}

const modal = ( options = {}) =>{
  return new Promise(res =>{
    const defaultOptions = {
      title:'提示',
      content:'您确定执行该操作吗？',
      confirmColor:'#ef3514f'
    }

    const opts = Object.assign({},defaultOptions,options)

    wx.showModal({
      ...opts,
      complete({confirm,cancel}){
        confirm && res(true)
        cancel && res(false)
      }
    })
  })
}

wx.toast = toast
wx.modal = modal